package br.com.SAM.Bean;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;

import br.com.SAM.Interfaces.IMedicamento;
import br.com.SAM.modelos.Medicamento;
import br.com.SAM.modelos.Produto;

@Stateless(name="MedicamentoBean")
public class MedicamentoBean extends GenericBean implements IMedicamento {
	@PersistenceContext(name="sam")
	private EntityManager em;
	
	
	public Medicamento findById(long id) {
		Query q = em.createNamedQuery("medicamento.findById");
		q.setParameter("param", id);
		try{
			return (Medicamento) q.getSingleResult();
		}catch(NoResultException nre){
			return null;
		}
	}

	

}
